package com.hy.proxy.common;

import java.util.Base64;

/**
 * @Author: hy
 * @Date: Created in 2019/10/9/13:10
 * @Description: 加解密操作
 * @Version: 1.0
 */
public enum CipherUtils implements Cip {
    BASE64 {
        @Override
        public String encoder(String encoderStr) {
            return Base64.getEncoder().encodeToString(encoderStr.trim().getBytes());
        }

        @Override
        public String decoder(String decoderStr) {
            return new String(Base64.getDecoder().decode(decoderStr));
        }
    }
}

interface Cip {
    /**
     * 返回Base64加密了的字符串
     */
    String encoder(String encoderStr);

    /**
     * 返回Base64解密了的字符串
     */
    String decoder(String decoderStr);
}
